<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values" @change="change"></cfg-form>
</template>

<script>
const ref = "editView";
export default {
  name:ref,
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref,
      onlyRead: false,
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
   
  },
  watch: {},
  computed: {
    attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 3,
        columns: [
          {
            key: "planBatchNo",
            title: "计划批次号",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          // {
          //   key: "planType",
          //   title: "计划类型",
          //   minWidth: 100,
          //   align: "center",
          //   config: { type: "text" },
          // },
          {
            key: "productId",
            title: "产品规格",
            minWidth: 100,
            align: "center",
            config: { type: "select",options:this.anc.productOptions,disabled:true },
          },
          {
            key: "status",
            title: "状态",
            minWidth: 100,
            align: "center",
            config: { type: "text",readonly:true },
          },
          // {
          //   key: "routingId",
          //   title: "工艺路径",
          //   minWidth: 100,
          //   align: "center",
          //   config: { type: "number" },
          // },
          {
            key: "planStartTime",
            title: "计划开始时间",
            minWidth: 200,
            align: "center",
            config: { type: "datetime" },
          },
          {
            key: "planEndTime",
            title: "计划结束时间",
            minWidth: 200,
            align: "center",
            config: { type: "datetime" },
          },
          {
            key: "startTime",
            title: "实际开始时间",
            minWidth: 200,
            align: "center",
            config: { type: "datetime" },
          },
          {
            key: "endTime",
            title: "实际结束时间",
            minWidth: 200,
            align: "center",
            config: { type: "datetime" },
          },
          {
            key: "totalCapacity",
            title: "计划产量",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "usedCapacity",
            title: "已产量",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "restCapacity",
            title: "剩余未产",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "df_maxFSSS",
            title: "最大FSSS",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "df_minFSSS",
            title: "最小FSSS",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "df_maxCT",
            title: "最大CT",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "df_minCT",
            title: "最小CT",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "remark",
            title: "备注",
            minWidth: 100,
            align: "center",
            config: { type: "textarea" },
          },
        ],
        rules: {
          planBatchNo: [{ required: true, message: "请输入", trigger: "blur" }],
        },
      };
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        fn(valid);
      });
    },
    // validate() {
    //   this.loading = true;

    //   this.$refs[this.ref].$refs["form"].validate((valid) => {
    //     if (valid) {
    //       let data = this.data;
    //       this.anc.models.template.clz.setRecord(data);
    //       this.anc.models.template.clz.update().then((flag) => {
    //         if (flag) {
    //           this.loading = false;
    //           this.anc.vms.editModal.show = false;
    //           this.anc.vms.inspectionTable.loadPage(
    //             this.anc.vms.table.pageNavigation,
    //             {}
    //           );
    //         } else {
    //           this.loading = false;
    //         }
    //       });
    //     } else {
    //       this.$Message.info("请填写必填内容");
    //     }
    //   });
    // },
    change(type, item) {
      if (type == 'sf_maintainCycle') {
        this.anc.change(type,item)
      }
    },
  },
};
</script>
<style scoped></style>
